{% extends "admin/layout.html" %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card shadow mb-4">
                <div class="card-header py-3 d-flex justify-content-between align-items-center">
                    <h6 class="m-0 font-weight-bold text-primary">系统配置</h6>
                </div>
                <div class="card-body">
                    <form method="POST" action="{{ url_for('admin.admin_config.system_config') }}">
                        {{ form.hidden_tag() }}

                        <div class="row mb-4">
                            <div class="col-md-12">
                                <h5 class="text-primary mb-3">网站信息</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.site_name.label(class="form-label") }}
                                    {{ form.site_name(class="form-control", required=True,
                                                    **{'aria-describedby': 'site-name-error' if form.site_name.errors else ''}) }}
                                    {% for error in form.site_name.errors %}
                                        <span id="site-name-error" class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.site_title.label(class="form-label") }}
                                    {{ form.site_title(class="form-control", required=True,
                                                     **{'aria-describedby': 'site-title-error' if form.site_title.errors else ''}) }}
                                    {% for error in form.site_title.errors %}
                                        <span id="site-title-error" class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.site_keywords.label(class="form-label") }}
                                    {{ form.site_keywords(class="form-control") }}
                                    {% for error in form.site_keywords.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.site_description.label(class="form-label") }}
                                    {{ form.site_description(class="form-control") }}
                                    {% for error in form.site_description.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-12">
                                <h5 class="text-primary mb-3">公司信息</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.company_name.label(class="form-label") }}
                                    {{ form.company_name(class="form-control") }}
                                    {% for error in form.company_name.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.company_address.label(class="form-label") }}
                                    {{ form.company_address(class="form-control") }}
                                    {% for error in form.company_address.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.contact_phone.label(class="form-label") }}
                                    {{ form.contact_phone(class="form-control") }}
                                    {% for error in form.contact_phone.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.contact_email.label(class="form-label") }}
                                    {{ form.contact_email(class="form-control") }}
                                    {% for error in form.contact_email.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-12">
                                <h5 class="text-primary mb-3">其他设置</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.timezone.label(class="form-label") }}
                                    {{ form.timezone(class="form-select") }}
                                    {% for error in form.timezone.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.footer_info.label(class="form-label") }}
                                    {{ form.footer_info(class="form-control") }}
                                    {% for error in form.footer_info.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    {{ form.icp_number.label(class="form-label") }}
                                    {{ form.icp_number(class="form-control") }}
                                    {% for error in form.icp_number.errors %}
                                        <span class="text-danger">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-12">
                                <div class="form-check form-switch">
                                    {{ form.operation_log_enabled(class="form-check-input") }}
                                    {{ form.operation_log_enabled.label(class="form-check-label") }}
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12">
                                <button type="submit" class="btn btn-primary" aria-label="保存系统配置">
                                    <i class="fas fa-save me-1"></i> 保存配置
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}